<%@page contentType="text/html; charset=utf-8" %>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/messages.jsp"%>
<%@ include file="/commons/commonEdit.jsp" %>
<%@ include file="/commons/validation.jsp" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<script language="javaScript" type="text/javascript" src="${ctx}/pages/com/ce/pms/charge/cashiering/otherPayMode.js"></script>
<script type="text/javascript" src="${ctx}/scripts/common.js"></script>
<script type="text/javascript" src="${ctx}/scripts/div/common.js"></script>
<script>

 var currentRecordId="";
var divListObj = null;
var currentOperationTypeArray=[];
function showResult(){

 var objj = findFrame("otherPayBillList");

      if(objj.getChargeRecords()==''){
        return false;
      }

		var isRequiredValidate=false;
        for(var i=0;i<currentOperationTypeArray.length;i++){
           var OperationType=currentOperationTypeArray[i].split("_")[0];
           if(OperationType=="001" || OperationType=="004" || OperationType=="005"){

              isRequiredValidate=true;
              break;

            }

        }

       var isTrue=false;
       if(isRequiredValidate){
       isTrue=$('otherPayBillForm').fireEvent("onSubmit");
       }else{
       isTrue=true;
       }

	    if(isTrue){

	    document.getElementById("chargeRecords").value= objj.getChargeRecords();

	    $('payMode').value= divListObj.getResult();
	    $('notCredit').value=isRequiredValidate;

	        var url = "${ctx}/charge_cashieringAction.do?method=handleChargeRecords";
	        var param = Form.serialize('otherPayBillForm');
	        new Ajax.Request(url,{method: 'post',parameters :param ,onSuccess : showResponse});
		}
	}
function showResponse(response){
	if(response.responseText == "true" ){
	    refreshList();
	    var obj = findFrame("connTabPanel");
	    obj.refresh();

	    var len = $("layer1").rows.length;
	    for(var i = 0; i < len;i++)
	    	$("layer1").deleteRow();
	    divListObj = new sectionChargeObj("layer1","${payModeStr}");
	    divListObj.initTbody();
	    document.getElementById("remark").disabled=false;

    }
    else
       ajaxSubmitException(response.responseText);
}
function myclose(){
   parent.myClose();
}

function setcurrentRecordId(id){
currentRecordId=id;
}

   function deleteAsk(){
	   AskConfirm("您确定要删除此条记录吗？","connTabPanelCharge","deleteReorcd");
	}

	function deleteReorcd(){

      var url = "${ctx}/charge_cashieringAction.do?method=deleteChargeRecord&chargeRecordId="+currentRecordId;
		        new Ajax.Request(url,{method: 'post',parameters :null ,onSuccess : showResponse});

	}

	function monthBalance(){
	var url = "${ctx}/charge_cashieringAction.do?method=monthBalance&accountHouseId=${accountHouseId}&keyword="+currentRecordId;
		        new Ajax.Request(url,{method: 'post',parameters :null ,onSuccess : showResponse});

	}

	function refreshList(){
	currentRecordId='';
	window.document.all('otherPayBillList').src="${ctx}/charge_cashieringAction.do?method=otherPayBillList&accountHouseId=${accountHouseId}";
	}

function setSumCountAdd(sum){
var sumContext=document.getElementById("sumCount").innerHTML;
  var addSum = Number(sum);
  var sumCount= Number(sumContext);
  //document.getElementById("sumCount").innerHTML=sumCount+addSum;
   document.getElementById("sumCount").innerHTML=parseFloat(sumCount+addSum).toFixed(2);
   document.getElementById("credit").value=parseFloat(sumCount+addSum).toFixed(2);
   $('layer1').getElementsByTagName('INPUT')[0].value=parseFloat(sumCount+addSum).toFixed(2);
}

function setSumCountR(sum){
var sumContext=document.getElementById("sumCount").innerHTML;
  var addSum = Number(sum);
  var sumCount= Number(sumContext);
  //document.getElementById("sumCount").innerHTML=sumCount-addSum;
  document.getElementById("sumCount").innerHTML=parseFloat(sumCount-addSum).toFixed(2);
  document.getElementById("credit").value=parseFloat(sumCount-addSum).toFixed(2);
  $('layer1').getElementsByTagName('INPUT')[0].value=parseFloat(sumCount-addSum).toFixed(2);


}

function initSumCount(){
document.getElementById("sumCount").innerHTML=0;
document.getElementById("credit").value=0;
}

function isAllowAdd(){
    var CountOperationType=0;
  for(var i=0;i<currentOperationTypeArray.length;i++){
   var OperationType=currentOperationTypeArray[i].split("_")[0];
    if(OperationType=="001" || OperationType=="004" || OperationType=="005"){
    CountOperationType=CountOperationType+1;
      if(CountOperationType>1){
      Alert("您选择的收费项目将跨子帐户入账，不能采用多种支付方式");
      return true;
      }
    }

  }
  if(CountOperationType==0 && currentOperationTypeArray.length>0){
  return true;
  }
  return false;
}

function deletePayModel(){

  var CountOperationType=0;
  for(var i=0;i<currentOperationTypeArray.length;i++){
   var OperationType=currentOperationTypeArray[i].split("_")[0];
    if(OperationType=="001" || OperationType=="004" || OperationType=="005"){
    CountOperationType=CountOperationType+1;
      if(CountOperationType>1){
       var urrentCountPayModel=getCurrentCountPayModel();
        for(var m=1;m<urrentCountPayModel;m++){
       document.getElementById("deleteTable_01").onclick();
       }
       break;
      }
    }

  }


  if(CountOperationType==0 && currentOperationTypeArray.length>0){

      var urrentCountPayModel=getCurrentCountPayModel();
        for(var m=1;m<urrentCountPayModel;m++){
       document.getElementById("deleteTable_01").onclick();
       }
       //当只选中002和003时，金额和支付交易码不能编辑
      $('layer1').getElementsByTagName('INPUT')[0].disabled=true;
      $('layer1').getElementsByTagName('SELECT')[0].disabled=true;
      document.getElementById("remark").disabled=true;


  }else{
     //当不只选中002和003时，金额和支付交易码可以编辑
     $('layer1').getElementsByTagName('INPUT')[0].disabled=false;
     $('layer1').getElementsByTagName('SELECT')[0].disabled=false;
     document.getElementById("remark").disabled=false;
  }

}

function setOperationTypeArray(OperationTypeArray){
  currentOperationTypeArray=OperationTypeArray
}


</script>
</head>
<body onload="init();">
<div    class="tab_bgline" >

<div id="cc" style="height:480px;overflow:auto;" >

<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tab_line">
                        <tr>
                          <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0" >

                              <tr>
                                <td colspan="5" >
									 <iframe src="${ctx}/charge_cashieringAction.do?method=otherPayBillList&accountHouseId=${accountHouseId}" name="otherPayBillList" id="otherPayBillList" width="100%"  height="250px"  frameborder="0" border="0"  scroll="yes" ></iframe>
								</td>
                              </tr>
</table>
</div>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td valign="middle" class="content">
    <form name="otherPayBillForm" method="post" action="" class="required-validate">
    <input type="hidden" name="isVirtual" value="${isVirtual}">
    <input type="hidden" name="chargeRecords" value="">
     <input type="hidden" name="payMode">
     <input type="hidden" name="credit">
     <input type="hidden" name="notCredit">
     <input type="hidden" name="accountHouseId" value="${accountHouseId}">
	<table width="100%" border="0" cellspacing="0" cellpadding="0">

          <tr>
          	<td colspan="4">
				<table width="100%" border="0" cellspacing="0" cellpadding="0"  class='gridData2'>
                 <tr  class="grid2">
                 <td class="chareg_hj"><strong>${key.countMonery}</strong></td>
              <td class="chareg_hj">&nbsp;</td>
              <td class="chareg_hj">&nbsp;</td>
              <td align="right" class="chareg_hj"><span class="font_red" id="sumCount">0</span><strong>元</strong>&nbsp;</td>
              <td class="chareg_hj">&nbsp;</td>
              <td class="chareg_hj">&nbsp;</td>
              <td class="chareg_hj">&nbsp;</td>
                        </tr>
                </table>
              </td>
          </tr>
          <tbody id="layer1">
		  </tbody>
		  <tr>
              <td colspan="4" valign="top" class="aux_titletable">${key.charge_paybill_remark}</td>
            </tr>
          <tr>
            <td valign="top" class="aux_intable_td1">${key.charge_paybill_remark}：</td>
            <td colspan="3" class="aux_intable_td2"><textarea name="remark" cols="50" rows="3"></textarea></td>
           </tr>

      </table>
	</form>
    </td>
  </tr>


  <tr>
    <td class="window_footer"><table border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_61"></td>
              <td class="buttonOffMiddle" id="btn1_62" onClick="showResult();" onMouseOver="btn_change_over(6)" onMouseOut="btn_change_out(6)" onBlur="btn_change(6)"><img src="${ctx}/images/ico_ok.gif" alt="" width="14" height="14" border="0" align="absbottom">${key.save}</td>
              <td class="buttonOffRight" id="btn1_63"></td>
            </tr>
        </table></td>
        <td class="btn_between_space"></td>
        <td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_91"></td>
              <td class="buttonOffMiddle" id="btn1_92" onClick="myclose();" onMouseOver="btn_change_over(9)" onMouseOut="btn_change_out(9)" onBlur="btn_change(9)"><img src="${ctx}/images/ico_cancel.gif" alt="" width="14" height="14" border="0" align="absbottom"> ${key.close}</td>
              <td class="buttonOffRight" id="btn1_93"></td>
            </tr>
        </table></td>
      </tr>
    </table>
    <p>&nbsp;</p></td>
  </tr>
</table>
</div>
</body>
<script defer>
function init(){
	divListObj = new sectionChargeObj("layer1","${payModeStr}");
	divListObj.initTbody();

}
</script>
</html>